import { defHttp } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';
import { PhysicalListParams } from '@/api/peis/model/peis';
import { DeleteParams } from '@/api/model/baseModel';

enum Api {
  PhysicalList = '/tj/tjPhysical/list', //查询体检记录
  PhysicalDeleteByID = '/tj/tjPhysical/getByDeltedByID', //删除体检记录
  PhysicalBatchDelete = '/tj/tjPhysical/batchDelete', //批量删除体检记录
  QueryByTcId = '/publicHygiene/tj/tjcombination/queryByTcId?tcId=1', //获取科室数据
  QueryByBarcode = '/tj/tjProject/queryByBarcode', // 获取体检数据
}

/**
 * 查询体检记录
 * @param params 查询参数
 * @param mode 错误modal
 */
export function getPhysicalList(params: PhysicalListParams, mode: ErrorMessageMode = 'modal') {
  //params.params = { page: '1', limit: '10' };
  return defHttp
    .post(
      {
        url: Api.PhysicalList,
        params,
      },
      {
        errorMessageMode: mode,
      },
    )
    .then((res) => {
      return res.page;
    });
}

/**
 * 删除体检记录
 * @param params ID
 * @param mode  错误modal
 */
export function deletePhysicalByID(params: DeleteParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.PhysicalDeleteByID,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 批量删除体检记录
 * @param params ID数组
 * @param mode 错误modal
 */
export function batchDeletePhysical(params: [], mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.PhysicalBatchDelete,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 获取体检科室数据
 * @param params 查询参数
 * @param mode 错误modal
 */
export function queryByTcId(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.QueryByTcId,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 获取体检数据
 * @param params 查询参数
 * @param mode 错误modal
 */
export function queryByBarcode(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.QueryByBarcode,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
